#pragma once
#include<stdio.h>
#include<typeinfo>
template<typename T>
T** Alloc_Matrix(int row, int col, T val)
{

    T** matrix = new T*[row];
    for(int i = 0; i < row; ++i)
        matrix[i] = new T[col]();
    return matrix;
}

template<typename T>
void Free_Matrix(T** matrix, int row)
{
    for(int i = 0; i < row; ++i)
        delete [] matrix[i];
    delete [] matrix;
}

template<typename T>
void Print_Matrix(T** matrix, int row, int col)
{
    for(int i = 0; i < row; ++i)
    {
        for(int j = 0; j < col; ++j)
        {
            if(typeid(double) == typeid(T) || typeid(float) == typeid(T))
                printf("%15.6f ", matrix[i][j]);
            else printf("%8d ", matrix[i][j]);
        }
        printf("\n");
    }
}

template<typename T>
void Print_Vector(T* vec, int size)
{
    for(int i = 0; i < size; ++i)
    {
        if(typeid(double) == typeid(T) || typeid(float) == typeid(T))
            printf("%15.6f ", vec[i]);
        else printf("%8d ", vec[i]);
    }
    printf("\n");
}
